package com.rslai.base.tool.servertest.command;

import com.rslai.base.tool.servertest.context.Context;
import com.rslai.base.tool.servertest.model.KeyValueStore;
import com.rslai.base.tool.servertest.response.Response;
import com.rslai.base.tool.servertest.transport.http.HttpService;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class RemoveHeaderCommand extends StepCommand {
    private String header;

    public RemoveHeaderCommand(String header) {
        this.header = header;
    }

    public Response doExecute(Response param, Context context) throws Throwable {
        HttpService.removeHeader(this.header);
        return param;
    }

    protected StepCommand doClone() {
        return new RemoveHeaderCommand(this.header);
    }

    public Map<String, Object> toReport() {
        Map details = new HashMap();
        details.put("stepName", "删除指定HTTP头:");
        List params = new ArrayList();
        params.add(new KeyValueStore("header", this.header));
        details.put("params", params);
        return details;
    }
}
